<template>
  <el-dialog
    :title="title"
    :visible.sync="dialogVisible"
    width="60%">
    <el-form class="handleform" :disabled="disabledHead" ref="handleform" label-position="left"  :model="data" size="small" label-width="130px">
    	<el-row :gutter="20">
        <el-col :span="12">
        	<el-form-item label="仪器名称" >
        		<el-input
        			v-model="data.equipmentName"
        			:disabled="disabledHead"
        		/>
        	</el-form-item>
        </el-col>
        <el-col :span="12">
        	<el-form-item label="单位名称" >
            <entrustSelect :eid="data.entrustOrganizationId" :name="data.entrustOrganizationName "></entrustSelect>
        	</el-form-item>
        </el-col>
    	</el-row>
      <el-row :gutter="20">
        <el-col :span="12">
        	<el-form-item label="检测人">
        		<el-input
        			v-model="data.testerName"
        			disabled
        		/>
        	</el-form-item>
        </el-col>
        <el-col :span="12">
        	<el-form-item label="任务类型" >
        		<el-select v-model="data.resultType">
              <el-option
                label="个人剂量"
                value="DOSE"
              ></el-option>
              <el-option
                label="设备质量控制"
                value="DEVICE"
              ></el-option>
            </el-select>
        	</el-form-item>
        </el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col :span="12">
        	<el-form-item label="受检设备类型名称">
        		<el-input
        			v-model="data.entrustEquipmentName"
        			disabled
        		/>
        	</el-form-item>
        </el-col>
        <el-col :span="12">
        	<el-form-item label="受检设备类型编码">
        		<el-input
        			v-model="data.entrustEquipmentTypeCode"
        			disabled
        		/>
        	</el-form-item>
        </el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col :span="12">
        	<el-form-item label="受检设备编号">
        		<el-input
        			v-model="data.entrustEquipmentNumber"
        			disabled
        		/>
        	</el-form-item>
        </el-col>
        <el-col :span="12">
        	<el-form-item label="使用时间">
        	  <el-date-picker
        	    v-model="createTime"
        	    type="datetimerange"
        	    range-separator="至"
        	    start-placeholder="开始"
        	    end-placeholder="结束"
        	    align="right">
        	  </el-date-picker>
        	</el-form-item>
        </el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col :span="8">
        	<el-form-item label="检测前状态" >
        		<el-select v-model="data.useBefore">
        	    <el-option v-for="(item,key,index) in checkState" :key="key" :label="item" :value="key"
        	    ></el-option>
        	  </el-select>
        	</el-form-item>
        </el-col>
        <el-col :span="8">
        	<el-form-item label="检测时状态" >
        		<el-select v-model="data.useThen">
        	    <el-option v-for="(item,key,index) in checkState" :key="key" :label="item" :value="key"
        	    ></el-option>
        	  </el-select>
        	</el-form-item>
        </el-col>
        <el-col :span="8">
        	<el-form-item label="检测后状态" >
        		<el-select v-model="data.useAfter">
        	    <el-option v-for="(item,key,index) in checkState" :key="key" :label="item" :value="key"
        	    ></el-option>
        	  </el-select>
        	</el-form-item>
        </el-col>
      </el-row>
    </el-form>
    <template slot="footer" class="dialog-footer">
      <el-button @click="close">关闭</el-button>
    </template>
  </el-dialog>
</template>

<script>
  import {queryPageList} from '@/api/equipment/use'
  import entrustSelect from '@/components/select/src/entrustSelect'
  export default{
    name:'useRecordDialog',
    components:{entrustSelect},
    data(){
      return {
        dialogVisible:false,
        title:'使用记录详情',
        disabledHead:true,
        data:{
          entrustOrganizationName:''
        },
        checkState:{
          'NORMAL':'正常',
          'DAMAGE':'损坏'
        }
      }
    },
    computed:{
      createTime:{
        get(){
          return (this.data.createTimeStart&&this.data.createTimeEnd) ? [new Date(this.data.createTimeStart),new Date(this.data.createTimeEnd)] : null
        },
        set(val){
          this.data.createTimeStart = val ? this.parseTime(val[0]):null
          this.data.createTimeEnd = val ? this.parseTime(val[1]): null
        }
      }
    },
    methods:{
      close(){
        this.dialogVisible = false
      },
      async open(id,type){
        await this.getInfo(id)
        this.dialogVisible = true
      },
      async getInfo(id){
        let res = await queryPageList({equipmentId:id})
        this.data = res.rows[0]
      }
    }
  }
</script>

<style>
</style>
